<%--
  Created by IntelliJ IDEA.
  User: HW
  Date: 2018/4/19
  Time: 1:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <script type="text/javascript" src="../../js/jquery-1.11.0.js"></script>
    <script type="text/javascript" src="../../js/jquery-migrate-1.2.1.js"></script>
    <script src="../../js/jquery.js"></script>
</head>
<body style="background: cornflowerblue;">
<div style="height: 100%;width: auto;" align="center">

    <table border="0" style="margin-top: 20%;" id="usertable">
        <form action="/user/register" method="post">
            <tr>
                <td><h1>乡镇图书管理系统登录</h1></td>
            </tr>
            <tr align="center">
                <td><p>用户&nbsp;名:<input id="userName" name="userName" type="text" onblur="yzUserName()"/></p></td>
            </tr>
            <tr align="center">
                <td><p>密&nbsp;&nbsp;码:<input id="password1" name="password1" type="password"/></p></td>
            </tr>
            <tr align="center">
                <td><p>确认密码:<input id="password2" name="password2" type="password"/></p></td>
            </tr>
            <tr align="center">
                <%--<td align="right"><p><a href="login.jsp" style="margin-right: 40px">忘记密码</a></p></td>--%>
            </tr>
            <tr align="center">
                <td align="center"><input type="submit" value="注册" onclick="return yzpassword()">
            </tr>
        </form>
    </table>
</div>
</body>
<script type="text/javascript">
    function yzUserName() {
        $.ajax({
            type:"post",
            url:"/user/yzUserName",
            dataType:"json",
            data:{
                userName:$("#userName").val()
            },
            success:function (data) {
                if(data==0){
                    alert("用户名已存在！")
                }
            }
        })
    }
    
    function yzpassword() {
        if($("#password1").val()!=$("#password2").val()){
            alert("输入密码不一致，请重新输入");
            return false;
        }else {
            return true;
        }
    }
</script>
</html>
